Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added part of the 'String Commands' group to RedisClient as specified on the official Redis website. #68

Conversation

SanHalacogluImproving
Copy link

No description provided.

@@ -318,4 +318,170 @@ public void set_withOptionsOnlyIfDoesNotExist_success()
assertNotNull(response);
assertEquals(value, response.get());
}

@Test
public void decr_success() throws ExecutionException, InterruptedException {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are we planning to add non-successful cases?

acarbonetto and others added 5 commits January 25, 2024 16:15
* Add base command; add custom command

---------

Signed-off-by: Andrew Carbonetto <[email protected]>
Signed-off-by: Andrew Carbonetto <[email protected]>
@SanHalacogluImproving SanHalacogluImproving force-pushed the java/integ_SanH_StringCommands branch from df8b07d to 1dcc052 Compare January 26, 2024 00:21
@SanHalacogluImproving SanHalacogluImproving force-pushed the java/dev_SanH_StringCommands branch from 6340d2f to c8a54bb Compare January 26, 2024 00:25
java/client/src/main/java/glide/api/RedisClient.java Outdated Show resolved Hide resolved
*
* @see <a href="https://redis.io/commands/decr/">redis.io</a> for details.
* @param key - The key to decrement its value.
* @return the value of `key` after the decrement. An error is raised if `key` contains a value of

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
* @return the value of `key` after the decrement. An error is raised if `key` contains a value of
* @return The value of `key` after the decrement. An error is raised if `key` contains a value of

Keep the casing consistend across the docs (update below too)

java/client/src/main/java/glide/api/RedisClient.java Outdated Show resolved Hide resolved
import java.util.concurrent.CompletableFuture;

/** String Commands interface to handle single commands that return Strings. */
/**
* String Commands interface.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could be a bit confusing, becase string commands don't return strings actually.

Suggested change
* String Commands interface.
* Commands that perform string manipulation.

java/client/src/test/java/glide/api/RedisClientTest.java Outdated Show resolved Hide resolved

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I propose to leave here tests which required to provide test coverage, but all meaningful test move to IT, where you can execute a command without mocking anything.
Probably, wait for valkey-io#863 to merge or rebase on IT test branch.

@Yury-Fridlyand
Copy link

Yury-Fridlyand commented Jan 26, 2024

Please, also fix CI (again spotless, oh) and update PR description with examples and list of commands implemented

* @see <a href="https://redis.io/commands/incrby/">redis.io</a> for details.
* @param key - The key to increment its value.
* @param amount - The amount to increment.
* @returns the value of `key` after the increment, An error is raised if `key` contains a value

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Important: the tag should be @return - please update everywhere

Suggested change
* @returns the value of `key` after the increment, An error is raised if `key` contains a value
* @return The value of `key` after the increment, An error is raised if `key` contains a value

* @param msg - the ping argument that will be returned.
* @returns return a copy of the argument.
* @param msg The ping argument that will be returned.
* @return Return a copy of the argument.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: Seems like in the other docs we don't do "@return Return"

Suggested change
* @return Return a copy of the argument.
* @return A copy of the argument.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
* @return Return a copy of the argument.
* @return A server response

* @param key The key to store.
* @param value The value to store with the given key.
* @param options The Set options
* @return String or null If value isn't set because of `onlyIfExists` or `onlyIfDoesNotExist`

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: taking this from the python client docs:

Suggested change
* @return String or null If value isn't set because of `onlyIfExists` or `onlyIfDoesNotExist`
* @return The old value as a string if `returnOldValue` is set. Otherwise, if the value isn't set because of `onlyIfExists` or `onlyIfDoesNotExist`, return null. Otherwise, return "OK".

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

use {@link returnOldValue} (add proper link) instead of just `returnOldValue`

*
* @see <a href="https://redis.io/commands/incr/">redis.io</a> for details.
* @param key The key to increment its value.
* @return The value of `key` after the increment, An error is raised if `key` contains a value of

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: this should be a period instead of comma, same thing applies for other occurrences in this PR

Suggested change
* @return The value of `key` after the increment, An error is raised if `key` contains a value of
* @return The value of `key` after the increment. An error is raised if `key` contains a value of

* @param args arguments for the custom command
* @return a CompletableFuture with response result from Redis
* @param args Arguments for the custom command
* @return A CompletableFuture with response result from Redis

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As we discussed, you can simplify that - here and for all other functions (except CreateClient I think)

Suggested change
* @return A CompletableFuture with response result from Redis
* @return A response from Redis

@@ -92,7 +94,7 @@ public CompletableFuture<Object> customCommand(String[] args) {
* Ping the Redis server.
*
* @see <a href="https://redis.io/commands/ping/">redis.io</a> for details.
* @returns the String "PONG"
* @return The String "PONG"

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
* @return The String "PONG"
* @return A server response

* @param msg - the ping argument that will be returned.
* @returns return a copy of the argument.
* @param msg The ping argument that will be returned.
* @return Return a copy of the argument.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
* @return Return a copy of the argument.
* @return A server response

@@ -133,7 +135,7 @@ public CompletableFuture<Map> info() {
* Get information and statistics about the Redis server.
*
* @see <a href="https://redis.io/commands/info/">redis.io</a> for details.
* @param options - A list of InfoSection values specifying which sections of information to
* @param options A list of InfoSection values specifying which sections of information to

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
* @param options A list of InfoSection values specifying which sections of information to
* @param options A list of {@link InfoSection} values specifying which sections of information to

@@ -133,7 +135,7 @@ public CompletableFuture<Map> info() {
* Get information and statistics about the Redis server.
*
* @see <a href="https://redis.io/commands/info/">redis.io</a> for details.
* @param options - A list of InfoSection values specifying which sections of information to
* @param options A list of InfoSection values specifying which sections of information to
* retrieve. When no parameter is provided, the default option is assumed.
* @return CompletableFuture with the response

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
* @return CompletableFuture with the response
* @return A server response

Comment on lines +333 to +340
List<String> flatMap = new ArrayList<>();

for (Map.Entry<String, String> entry : keyValueMap.entrySet()) {
flatMap.add(entry.getKey());
flatMap.add(entry.getValue());
}

String[] args = flatMap.toArray(new String[0]);

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you can avoid creating intermediate list for better performance

public interface StringCommands {

CompletableFuture<String> get(String key);

CompletableFuture<Void> set(String key, String value);

CompletableFuture<String> set(String key, String value, SetOptions options);

CompletableFuture<Long> decr(String key);

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

move all javadocs from client to here - for all functions.

@Test
public void set_withOptionsOnlyIfExists_success()
throws ExecutionException, InterruptedException {
public void set_withOptionsOnlyIfExists_success() {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please rename the test

@Test
public void set_withOptionsOnlyIfDoesNotExist_success()
throws ExecutionException, InterruptedException {
public void set_withOptionsOnlyIfDoesNotExist_success() {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

here too


@SneakyThrows
@Test
public void decr_success() {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

consider moving new tests to new file(s)

@SanHalacogluImproving SanHalacogluImproving deleted the java/dev_SanH_StringCommands branch February 6, 2024 17:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants